import React, { createContext, useReducer } from 'react'
import { userInfo } from './pages/store/store'
import './App.css'
import 'antd/dist/antd.css' // or 'antd/dist/antd.less'
import Router from './router/router'
export const AppContext = createContext<any>({})
// Context 提供者下的 React 组件尽可能使用 React.memo
// 这样，父组件中的状态更新将不会强制每个组件重新渲染，只会强制渲染读取 context 的那部分
function App() {
  const allData = localStorage.getItem('allData')
  const initData = allData ? JSON.parse(allData) : {}
  const [store, dispatch] = useReducer(userInfo, initData)
  return (
    <AppContext.Provider value={{ store, dispatch }}>
      <Router></Router>
    </AppContext.Provider>
  )
}
export default App
